package jia;

import java.util.Random;

import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Term;


public class random2 extends DefaultInternalAction {
	private static Random rnd;

	@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args)
		throws Exception {
	if (rnd == null)rnd = new Random();
	
	int posX = (int) ((NumberTerm) args[0]).solve();
    int posY = (int) ((NumberTerm) args[1]).solve();
    Term tarX = args[2];
    Term tarY = args[3];
    int newX = rnd.nextInt(20) + posX -5;  
    int newY = rnd.nextInt(20) + posY -5;
    boolean a = un.unifies(tarX, new NumberTermImpl(newX));
    boolean b = un.unifies(tarY, new NumberTermImpl(newY));
    return a && b;
}
}
